﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyClassLibrary
{

    public class Patient
    {
        public string 姓名 { get; set; }
        public int 病患ID { get; set; }
        public int 病歷號碼 { get; set; }

        public static List<Patient> GetPatient()
        {
            MyDB.MedicareDataClassesDataContext DB = new MyDB.MedicareDataClassesDataContext();

            List<Patient> list = new List<Patient>();

            var q = from p in DB.Patients
                    select new { p.病患ID, p.姓名, p.病歷號碼 };

            foreach (var i in q)
            {
                list.Add(new Patient { 病患ID = i.病患ID, 姓名 = i.姓名, 病歷號碼 = (int)i.病歷號碼 });
            }
            return list;
        }
    }

    public class frequency
    {
        public int fID { get; set; }
        public string fName { get; set; }
        public int fDay { get; set; }

        public static List<frequency> GetFrequency()
        {
            MyDB.MedicareDataClassesDataContext DB = new MyDB.MedicareDataClassesDataContext();
            List<frequency> list = new List<frequency>();
            var q = from p in DB.ExamFrequencies
                    select p;

            foreach (var i in q)
            {
                list.Add(new frequency { fID = i.檢驗頻率ID, fName = i.檢驗頻率, fDay = i.轉換天數 });
            }
            return list;
        }
    }

    public class Exam
    {
        public int eID { get; set; }
        public string eName { get; set; }

        public static List<Exam> GetExam()
        {
            MyDB.MedicareDataClassesDataContext DB = new MyDB.MedicareDataClassesDataContext();
            List<Exam> list = new List<Exam>();
            var q = from p in DB.ExamOverview
                    select p;

            foreach (var i in q)
            {
                list.Add(new Exam { eID = i.檢驗項目ID, eName = i.中文名稱 });
            }
            return list;
        }
    }

    public class ClsExamSchedule
    {
        public static List<MyDB.View_ExamSchedules> getSchedule()
        {
            global::MyDB.MedicareDataClassesDataContext DB = new MyDB.MedicareDataClassesDataContext();
            var q2 = from p in DB.View_ExamSchedules
                     select p;

            return q2.ToList();
        }

        public static int id;
        public static string buttonName;

    }

    public class DiagPatient
    {
        public int 醫囑資料ID { get; set; }
        public string 姓名  { get; set; }
        public int 病歷號碼 { get; set; }
    }
}
